package com.ukao.pad.presenter;



import com.ukao.pad.base.BasePresenter;
import com.ukao.pad.bean.BaseBean;
import com.ukao.pad.consts.Constant;
import com.ukao.pad.retrofit.ApiCallback;
import com.ukao.pad.view.AddStorageView;

import java.util.HashMap;

/**
 * Created by ukaodev on 2017/6/26.
 */

public class AddStoragePesenter extends BasePresenter<AddStorageView> {

    public AddStoragePesenter(AddStorageView view) {
        attachView(view);
    }





    public void finishstockIn( HashMap mHashMap  ) {
        mvpView.showLoading();
        addSubscription(apiStores.copestockIn(Constant.createParameter(mHashMap)),
                new ApiCallback<BaseBean>() {
                    @Override
                    public void onSuccess(BaseBean model) {

                        if (model.getHttpCode() == 200) {

                            mvpView.loadSuccess(model.getMsg());

                        }else{
                            mvpView.loadFail(model.getMsg());

                        }
                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                    mvpView.hideLoading();
                    }
                });
    }


    public void stockInUpdate( HashMap    mHashMap ) {
        mvpView.showLoading();
        addSubscription(apiStores.stockInUpdate(Constant.createParameter(mHashMap)),
                new ApiCallback<BaseBean>() {
                    @Override
                    public void onSuccess(BaseBean model) {
                        if (model.getHttpCode() == 200) {

                            mvpView.loadSuccess(model.getMsg());

                        }else{
                            mvpView.loadFail(model.getMsg());

                        }


                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }





}
